package com.chongbangbang.controller.recommend;


import com.chongbangbang.pojo.ObjectComment;
import com.chongbangbang.pojo.ObjectComment;
import com.chongbangbang.service.ObjectCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * recommend_object中的评论 前端控制器
 * </p>
 *
 * @author TP
 * @since 2022-03-19 15:23:55
 */
@RestController
@RequestMapping("/chong/recommend/objectComment")
@Api(tags = "recommend object comment", value = "recommend_object中的评论")
public class ObjectCommentController {

    @Autowired
    private ObjectCommentService objectCommentService;

    @ApiOperation("查询所有")
    @RequestMapping(value = "", method = RequestMethod.GET)
    public List<ObjectComment> get() {
        return objectCommentService.list();
    }


    @ApiOperation("根据ID查询")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ObjectComment getById(@PathVariable Integer id) {
        return objectCommentService.getById(id);
    }


    @ApiOperation("单个插入")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public boolean post(ObjectComment objectComment) {
        return objectCommentService.save(objectComment);
    }


    @ApiOperation("批量插入")
    @RequestMapping(value = "/_mcreate", method = RequestMethod.POST)
    public boolean postBatches(@ApiParam(value = "传ArrayList<ObjectComment>") ArrayList<ObjectComment> list) {
        return objectCommentService.saveBatch(list);
    }


    @ApiOperation("根据ID更新")
    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public boolean putById(@ApiParam(name = "id", value = "id要单独传") @PathVariable("id") Integer id, ObjectComment objectComment) {
        return objectCommentService.updateById(objectComment);
    }

    @ApiOperation("批量更新")
    @RequestMapping(value = "/_mupdate", method = RequestMethod.PUT)
    public boolean putBatches(@ApiParam(value = "传ArrayList<ObjectComment>") ArrayList<ObjectComment> list) {
        return objectCommentService.updateBatchById(list);
    }


    @ApiOperation("根据ID删除")
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    public boolean deleteById(@PathVariable Integer id) {
        return objectCommentService.removeById(id);
    }

    @ApiOperation("根据ID批量删除")
    @RequestMapping(value = "/_mdelete", method = RequestMethod.DELETE)
    public boolean deleteById(@ApiParam(value = "传ArrayList<Integer>") ArrayList<Integer> list) {
        return objectCommentService.removeById(list);
    }
}
